<?php

namespace app\api\controller\integral;

use app\api\BaseController;
use app\api\service\IntegralGoodsService;

class GoodsController extends BaseController
{
    /**
     * 获取积分商品
     * */
    public function index()
    {
        $param = $this->request->param();

        if (empty($param['store_id'])){
            return json(['code' => 0, 'msg' => '非法参数!']);
        }

        $integralGoodsList = IntegralGoodsService::getIntegralGoodsList($param);

        return json(['code' => 1, 'data' => $integralGoodsList,'msg' => '请求成功!']);
    }

    /**
     *
     * 积分商品详情
     * */

    public function read()
    {
        $integral_goods_id = $this->request->param('integral_goods_id/d');

        if (empty($integral_goods_id)){
            return json(['code' => 0, 'msg' => '非法参数!']);
        }

        $integralGoodsList = IntegralGoodsService::findIntegralGoods($integral_goods_id);

        return json(['code' => 1, 'data' => $integralGoodsList,'msg' => '请求成功!']);
    }
}